import request from '@/utils/request.js'

/**
 * 文件上传API
 * @param {File} file 要上传的文件对象
 * @returns {Promise} 包含上传结果的Promise
 */
export const uploadFileService = (file) => {
    const formData = new FormData()
    formData.append('file', file)
    return request.post('/api/upload', formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}

/**
 * 批量文件上传API
 * @param {File[]} files 要上传的文件数组
 * @returns {Promise} 包含上传结果的Promise
 */
export const uploadFilesService = (files) => {
    const formData = new FormData()
    files.forEach(file => {
        formData.append('files', file)
    })
    return request.post('/api/upload/batch', formData, {
        headers: {
            'Content-Type': 'multipart/form-data'
        }
    })
}
